home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / Development Tools & Languages / LockFile / SetLockBit.c next >
Encoding:
C/C++ Source or Header  |  1992-07-15  |  1.7 KB  |  67 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2.  *
  3.  *    Apple Macintosh Developer Technical Support
  4.  *
  5.  *  Installer 3.2 sample: Action Atoms
  6.  *
  7.  *    File:        SetLockBit.c -    c Source
  8.  *
  9.  *    by:            Rich Kubota
  10.  *
  11.  *    Copyright © 1990-1992 Apple Computer, Inc.
  12.  *    All rights reserved.
  13.  *
  14.  *    Purpose: Sample to demonstrate setting the file lock bit.  This action
  15.  *        atom code resource must be called through a post installation action
  16.  *        atom.  In the selector field, pass in the name of the target 'infs'
  17.  *        resource id.  The code resource gets the resource, converts the partial
  18.  *        path name field to a pascal string, then calls, SetFLock.  A result of 
  19.  *        true is always returned so as not to abort the installation.
  20.  *        
  21.  *        This action atom is designed for use by both Installer 3.2 and 3.3
  22.  *----------------------------------------------------------------------------*/
  23.  
  24. #if 0
  25.  
  26. C -r -b  SetLockBit.c
  27. Link -ra =resPurgeable -t rsrc -c RSED -rt infn=10000 ∂
  28.     -m SETLOCKBIT -sg SetLockBit ∂
  29.     SetLockBit.c.o ∂
  30.     "{Libraries}"Interface.o ∂
  31.     -o SetLockBit.rsrc
  32.  
  33. #endif
  34.  
  35. #include <Types.h>
  36. #include <Resources.h>
  37. #include <Files.h>
  38. #include "ActionAtomIntf.h"
  39.  
  40. /* define record structure of 'infs' resource so that we can access the target file path */
  41.  
  42. struct infsRec {
  43.     long    fileType;
  44.     long    creator;
  45.     long    creationDate;
  46.     short    fileSpecFlags;
  47.     Str255    pathName;
  48. };
  49.  
  50. typedef struct infsRec infsRec;
  51. typedef infsRec **infsHdl;
  52.  
  53. /* protoypes */
  54. void    makePStr(char *fm, char *to);
  55.  
  56.  
  57. pascal Boolean    SETLOCKBIT(AAPBRecPtr myAAPBPtr)
  58. {
  59.     OSErr    err;
  60.     infsHdl    resH;
  61.     
  62.     resH = (infsHdl)GetResource('infs', myAAPBPtr->aaRefCon);
  63.     if (resH)
  64.         err = SetFLock((*resH)->pathName, myAAPBPtr->targetVRefNum);
  65.     return true;
  66. }
  67.